import axios from 'axios';

export interface GroupVO {
  code: string; // 分组编码
  description: string; // 分组描述
  parentId: string;
  parentName?: string;
  id: string;
  defaultIpOrDomain: string;
  defaultPort: number;
  children: GroupVO[]; // 问题标题
}
export interface CreateGroupDTO {
  code: string; // 分组编码
  description: string; // 分组描述
  parentId: string;
  defaultIpOrDomain: string;
  defaultPort?: number;
}
export interface UpdateGroupDTO extends CreateGroupDTO {
  id: string;
}

export function getGroupList() {
  return axios.get<GroupVO[]>('hub/group/list');
}

export function createGroup(data: CreateGroupDTO) {
  return axios.post('hub/group/add', data);
}
export function updateGroup(data: UpdateGroupDTO) {
  return axios.post('hub/group/update', data);
}

export function getGroupDetail(id: string) {
  return axios.get<GroupVO>(`hub/group/detail?id=${id}`);
}

export function deleteGroup(id: string) {
  return axios.post(`hub/group/delete/${id}`);
}
